<template>
  <div>
    <div class="conlog-mokuai">
      <div class="paySet-index">
        <div class="conlog-name">
          <div class="conlog-name-font">
            <i class="el-icon-s-unfold"></i>
            数据列表
          </div>
        </div>
        <div class="conlog-content">
          <!-- 数据列表 -->
          <div>
            <el-table :data="tableData" border style="width: 100%">
              <el-table-column prop="name" label="支付方式名称" width="120" align="center"></el-table-column>
              <el-table-column prop="description" label="支付方式描述" align="center"></el-table-column>
              <el-table-column prop="state" label="是否启用" width="100" align="center">
                <template slot-scope="scope">
                  <el-switch v-model="scope.row.state" @change="getchange(scope.row.state)"></el-switch>
                </template>
              </el-table-column>
              <el-table-column prop="seq" label="排序" width="120" align="center"></el-table-column>
              <el-table-column fixed="right" label="操作" width="100" align="center">
                <template slot-scope="scope">
                  <el-button @click="handleClick(scope.row.id)" type="text" size="small">编辑</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>


<style>
/* 自定义 */

.conlog-mokuai {
  height: 700px;
  background-color: rgb(249, 249, 249);
  padding-top: 30px;
}
.paySet-index {
  width: 100%;
  margin: auto;
  background-color: rgb(255, 255, 255);
}
.conlog-name {
  width: 100%;
  height: 40px;
  background-color: rgb(240, 240, 240);
}
.conlog-name-font {
  height: 40px;
  line-height: 40px;
  margin-left: 20px;
  font-size: 14px;
}
.conlog-content {
  width: 100%;
}
</style>

<script>
import paySetApi from "@/api/settings/paySet";
export default {
  data() {
    return {
      // 列表数据
      tableData: []
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    getchange(mess) {
      console.log(mess); //输出true或者false
      // this.value2 = mess; //赋值
    },
    fetchData() {
      paySetApi.findAll().then(response => {
        const resp = response.data;
        this.tableData = resp.data;
        resp.data.forEach(item => {
          if (item.state == 0) {
            item.state = false;
          } else {
            item.state = true;
          }
        });
      });
    },
    handleClick(id) {
      this.$router.push({
        path: "/settings/paySetRedact",
        // path: " paySetRedact",
        query: { id: id }
      });
    }
  }
};
</script>